home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / TVG121 / TVGRAPH.INT < prev    next >
Text File  |  1994-05-27  |  4KB  |  114 lines

  1. (* TVGRAPH.TPU provides all of the basic functions required by your       *)
  2. (* Graphics TURBOVISION application                                       *)
  3.  
  4. const
  5.  
  6. (* The following constants determine the graphics mode for TVG to work in *)
  7. (* NOTE the restrictions for each resolution                              *)
  8.  
  9.   smVGA320x200x16    = $00D;        (* Not available in BGI *)
  10.   smVGA640x200x16    = $00E;
  11.   smVGA640x350x16    = $010;
  12.   smVGA640x480x16    = $012;
  13.   smVesa800x600x16   = $102;        (* No mouse cursor - FUTURE VERSIONS *)
  14.   smVesa1024x768x16  = $104;        (* Not available yet  *)
  15.   smVesa1280x1024x16 = $106;        (* Not available yet  *)
  16.  
  17.  
  18.   smUseBGIInterface  = $200;        (* Use the BGI interface to init graphics *)
  19.   smUseTVGInterface  = $000;        (* Use the BIOS/VESA to init graphics     *)
  20.  
  21. (* Each graphics view has a co-ordinate system of 10000 by 7500    *)
  22. (* These are the constants for that co-ordinate system             *)
  23.  
  24.   GraphXMax          = 10000;
  25.   GraphYMax          = 7500;
  26.  
  27.   cmGraphDraw        = 191; (* Command constant for graphic draw of view *)
  28.   cmGraphProd        = 192; (* Prod command - allowing moving/continuous *)
  29.                             (*                graphics images            *)
  30.   cmGraphClear       = 193; (* Clear graphics view                       *)
  31.  
  32. type
  33.  
  34. (* graphics object - base level *)
  35.   pgObject = ^gObject;
  36.   gObject = object(TObject)
  37.     Color:byte;
  38.     constructor Init(C:byte);
  39.     procedure GraphDraw(R:TRect); virtual;
  40.     procedure GraphProd; virtual;
  41.     procedure ChangeColor(C:Byte);
  42.   end;
  43.  
  44. (* graphics line object *)
  45.   pgLine = ^gLine;
  46.   gLine = object(gObject)
  47.     Xa,Ya,Xb,Yb:integer;
  48.     constructor Init(X1,Y1,X2,Y2:integer;C:byte);
  49.     procedure GraphDraw(R:TRect); virtual;
  50.     procedure ChangeEnds(X1,Y1,X2,Y2:integer);
  51.     procedure ChangeEndsCopy(S:gLine);
  52.     procedure DeltaEnds(X1,Y1,X2,Y2:integer);
  53.   end;
  54.  
  55. (* graphics box object *)
  56.   pgBox = ^gBox;
  57.   gBox = object(gLine)
  58.     procedure GraphDraw(R:TRect); virtual;
  59.   end;
  60.  
  61. (* Use a gApp in your program just as you would use a TApplication object *)
  62.   pgApp = ^gApp;
  63.   gApp = object(TProgram)
  64.     GrMode:word;                (* Graphics mode of application *)
  65.     Prodable:boolean;           (* Prodable is TRUE for continuous updating *)
  66.     constructor Init(Mode:word);
  67.     destructor Done; virtual;
  68.     procedure SetScreenMode(Mode: Word);
  69.     procedure Idle; virtual;
  70. {$IFDEF Ver70}
  71.     procedure Cascade;
  72.     procedure DosShell;
  73.     procedure GetTileRect(var R: TRect); virtual;
  74.     procedure HandleEvent(var Event: TEvent); virtual;
  75.     procedure Tile;
  76.     procedure WriteShellMsg; virtual;
  77. {$ENDIF}
  78.   end;
  79.  
  80. (* Use a gView in your program where you want graphics functions within a view*)
  81.   pgView = ^gView;
  82.   gView = object(TView)
  83.     GraphWindowId:byte; (* The graphics window Id for this view *)
  84.     DisplayList:TCollection; (* List of gObjects
  85.     constructor Init(Var Bounds:Trect);
  86.     destructor Done;virtual;
  87.     procedure GraphProd;
  88.     procedure GraphDraw;
  89.     procedure GraphClear;
  90.     procedure Draw; virtual;
  91.     procedure HandleEvent(var Event:TEvent); virtual;
  92.     procedure ChangeBounds(var Bounds: TRect); virtual;
  93.     procedure Insert(P:pgObject);
  94.     procedure Delete(P:pgObject);
  95.   end;
  96.  
  97.  
  98. (* Use a gWindow for any Window that contains graphics views *)
  99.   pgWindow = ^gWindow;
  100.   gWindow = object(TWindow)
  101.     constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Integer);
  102.     procedure ChangeBounds(var Bounds: TRect); virtual;
  103.     procedure HandleEvent(var Event:TEvent);virtual;
  104.     procedure GraphDraw;
  105.     procedure GraphClear;
  106.     procedure GraphProd;
  107.   end;
  108.  
  109. procedure DrawLine(X1,Y1,X2,Y2:integer;Color:word);
  110. (* Draw a line from X1,Y1 to X2,Y2 in screen co-ordinates with clipping *)
  111. (* and graphics window ID protect, with mouse protection using color    *)
  112. procedure GlobalToPhysical(R:TRect;X0,Y0:integer;var X,Y:integer);
  113. (* Translate 10000x7500 co-ordinate in R to physical co-ordinate *)
  114.